<?php
namespace Kuoqi\Curl;
class Response{
	
	public $curl = null;
	private $resource = null;
	public $responseHead = null;
	public $response = null;
	
	public function __construct($curl){
		$this->curl = $curl;
		$this->resource = $curl->resource;
		$this->responseHead = curl_getinfo($this->resource);
		$this->response = curl_exec($this->resource);	
	}
	
	public function output($type){
		switch($type){
			case 'JSON':return $this->responseJson();
			default:return $this->response;	
		}
	}
	
	final function responseJson(){
		return 	json_decode($this->response,true);
	}
	
}